package com.cb.controller;

import com.cb.service.FilmService;
import com.cb.service.ScreeninFormationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.HashMap;

@RestController
@RequestMapping("/screeninformation")
@Api(value = "放映信息操作", description = "放映信息操作")
public class  ScreeninFormationController {

    @Autowired
    ScreeninFormationService screeninFormationService;

    @Autowired
    FilmService filmService;

    /**
     * 添加放映厅
     * @param json
     * @return
     */
    @PostMapping("/insertscreens")
    @ResponseBody
    @ApiOperation(value = "添加放映厅", notes = "添加放映厅")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "activeName", value = "查询的类型，一般为hot，comingsoon，classic"),
            @ApiImplicitParam(name = "countries", value = "国家"),
            @ApiImplicitParam(name = "type", value = "类型"),
            @ApiImplicitParam(name = "markettime", value = "上映时间"),
            @ApiImplicitParam(name = "page", value = "页码")
    })
    public String insertScreens(@RequestBody HashMap json, HttpServletRequest request){
        return screeninFormationService.insertScreens(json,request);
    }

    /**
     * 删除放映厅
     * @param json
     * @return
     */
    @PostMapping("/deletescreens")
    @ResponseBody
    @ApiOperation(value = "删除放映厅", notes = "删除放映厅")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yyid", value = "影院编号"),
            @ApiImplicitParam(name = "numberid", value = "放映厅id")
    })
    public String deletescreens(@RequestBody HashMap json, HttpServletRequest request)throws ParseException{
        return screeninFormationService.deletescreens(json,request);
    }

    /**
     * 修改放映厅
     * @param json
     * @return
     */
    @PostMapping("/updatascreens")
    @ResponseBody
    @ApiOperation(value = "修改放映厅", notes = "修改放映厅")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yyid", value = "影院编号"),
            @ApiImplicitParam(name = "numberid", value = "放映厅id"),
            @ApiImplicitParam(name = "number", value = "人数")
    })
    public String updatascreens(@RequestBody HashMap json, HttpServletRequest request)throws ParseException{
        return screeninFormationService.updatascreens(json,request);
    }

    /**
     * 查看所有放映厅
     * @return
     */
    @PostMapping("/selectscreens")
    @ResponseBody
    @ApiOperation(value = "查看所有放映厅", notes = "查看所有放映厅")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "yyid", value = "影院编号"),
    })
    public String selectscreens(@RequestBody HashMap json, HttpServletRequest request){
        return screeninFormationService.selectscreens(json,request);
    }

    /**
     * 初步销售统计
     * @param json
     * @return
     * @throws ParseException
     */
    @PostMapping("/sales")
    @ResponseBody
    @ApiOperation(value = "初步销售统计", notes = "初步销售统计 时间格式yyyy-MM-dd HH:mm:ss")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "begintime", value = "开始时间 "),
            @ApiImplicitParam(name = "endtime", value = "结束时间"),
            @ApiImplicitParam(name = "ypid", value = "影片id")
    })
    public String sales(@RequestBody HashMap json,HttpServletRequest request) throws ParseException {
        return screeninFormationService.sales(json,request);
    }

    /**
     * 设置折扣
     * @param json
     * @return
     */
    @PostMapping("/insertdiscount")
    @ResponseBody
    @ApiOperation(value = "设置折扣", notes = "设置折扣")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "discount", value = "优惠折扣"),
            @ApiImplicitParam(name = "multiple", value = "叠加倍数")
    })
    public String insertDiscount(@RequestBody HashMap json,HttpServletRequest request){
        return screeninFormationService.insertDiscount(json,request);
    }

    /**
     * 添加放映信息
     * @param json
     * @return
     */
    @PostMapping("/insertScreeninformation")
    @ResponseBody
    @ApiOperation(value = "添加放映信息", notes = "添加放映信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "自增主键，可以不填"),
            @ApiImplicitParam(name = "yyid", value = "影院id"),
            @ApiImplicitParam(name = "numberid", value = "某家影院第几家放映厅"),
            @ApiImplicitParam(name = "ypid", value = "影片id"),
            @ApiImplicitParam(name = "begintime", value = "开始时间，格式看数据库"),
            @ApiImplicitParam(name = "endtime", value = "结束时间，同上"),
            @ApiImplicitParam(name = "list", value = "不用传，后台自己生成")
    })
    public String insertScreeninformation(@RequestBody HashMap json, HttpServletRequest request) throws ParseException {
        return filmService.insertScreeninformation(json,request);
        //return "a";
    }

    /**
     * 查看放映信息
     * @param json
     * @return
     */
    @PostMapping("/selectScreeninformation")
    @ResponseBody
    @ApiOperation(value = "查看放映信息", notes = "查看放映信息")
    @ApiImplicitParams({

    })
    public String selectScreeninformation(@RequestBody HashMap json, HttpServletRequest request) throws ParseException {
        return screeninFormationService.selectScreeninformation(json,request);
        //return "a";
    }

    /**
     * 删除放映信息
     * @param json
     * @return
     */
    @PostMapping("/deleteScreeninformation")
    @ResponseBody
    @ApiOperation(value = "删除放映信息", notes = "删除放映信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "放映信息的编号"),
            @ApiImplicitParam(name = "ypid", value = "影片id")
    })
    public String deleteScreeninformation(@RequestBody HashMap json, HttpServletRequest request) throws ParseException {
        return screeninFormationService.deleteScreeninformation(json,request);
        //return "a";
    }

    /**
     * 更新放映信息
     * @param json
     * @return
     */
    @PostMapping("/updateScreeninformation")
    @ResponseBody
    @ApiOperation(value = "更新放映信息", notes = "更新放映信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "放映信息的编号"),
            @ApiImplicitParam(name = "yyid", value = "影院id"),
            @ApiImplicitParam(name = "numberid", value = "某个影院第一个放映厅"),
            @ApiImplicitParam(name = "ypid", value = "影片id"),
            @ApiImplicitParam(name = "begintime", value = "修改的开始时间"),
            @ApiImplicitParam(name = "endtime", value = "修改的结束时间")
    })
    public String updateScreeninformation(@RequestBody HashMap json, HttpServletRequest request) throws ParseException {
        return screeninFormationService.updateScreeninformation(json,request);
        //return "a";
    }

}
